Skip to content

fix: send a padded list, area or heading name trimmed when only that form matches - #456

Merged
ryanlewis merged 2 commits into
mainfrom
fix/trim-target-names
Oct 10, 2026
Merged

ryanlewis merged 2 commits into
mainfrom
fix/trim-target-names

Conversation

@ryanlewis

Copy link
Copy Markdown
Owner

Things matches a --list, --area or --heading title without trimming it, so --list " Tools " used to put the to-do in the Inbox, with only a warning. The CLI's lookups (db.AddTarget, db.AreaTarget, db.HeadingTarget) do the same, so they warned correctly but did not help.

Now add, project add, edit and project edit choose the name to send like this:

  1. As given, when Things matches it as given. A title that really has surrounding space, such as an area called Errands , is still reached by typing "Errands ".
  2. Trimmed, when only the trimmed name matches. Tools goes as Tools and lands with no warning.
  3. As given, when neither form matches. The warning is the same as before.

The lookup and the send now always use the same name. The helpers are addTargetName and areaTargetName in cmd/things/names.go. edit applies the rule to the heading too, both when it comes with a --list/--list-id and when it is looked up alone in the to-do's own project.

import does not trim. Its payload is Things' own format and goes as given, and it still warns about a padded name. commands.md, agents.md and SKILL.md say so.

Tests

  • TestTargetNamesSentTrimmedWhenOnlyThatMatches checks the URL that is sent for add, project add, edit and project edit. It covers padded names that only match trimmed, real padded titles (sent as given), and unknown names (sent as given, with a warning). On main it fails for every trimmed case.
  • In TestAddWarnsOnUnresolvedListOrHeading, TestProjectAddWarnsOnUnknownArea and TestEditWarnsOnUnresolvedMove, the padded cases now expect no warning and the right filing. The paddedTitle cases are unchanged and pass.

/code-review

  • Applied: the --list-id path in edit now goes through addTargetName, so a padded heading sent with --list-id is trimmed too (new case editListIDHeading); there is no heading retry when the list is an area, which has no headings.
  • Not applied: the "unknown list" warning in edit quotes the heading as typed, even when it will be sent trimmed (wording only). A padded list plus a padded heading can run one extra heading query (fixing it means changing db.AddTarget). resolveAddTarget/projectArea return the names through pointer parameters; returning them would be clearer but is only a matter of style.

@ryanlewis
ryanlewis merged commit f21ab03 into main Oct 10, 2026
10 checks passed
@ryanlewis
ryanlewis deleted the fix/trim-target-names branch October 10, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant